<?php

require("../config.php");
require_once($CONF['root.dir']."database.php");

if(strtoupper($_GET["modul"])=="EDIT"){
	$SQL="select id_pelamar,nama,tmp_lahir,tgl_lahir,alamat,telepon,jns_kelamin,status,pendidikan,jurusan,ipk from tbllamaran
		  where id_pelamar='".$_GET["data"]."'";
	$conn->connect();
	$val=$conn->query($SQL);
	$val->next();
	
	$id_pelamar     = $val->get(0);
	$nama 		 	= $val->get(1);
	$tmp_lahir 		= $val->get(2);
	$tgl_lahir 		= $val->get(3);
	$alamat 		= $val->get(4);
	$telepon 		= $val->get(5);
	$jns_kelamin 	= $val->get(6);
	$status 		= $val->get(7);
	$pendidikan 	= $val->get(8);
	$jurusan 		= $val->get(9);
	$ipk 		 	= $val->get(10);
	
	$BUTTON="Update";
	$P = array($pendidikan => "selected");
	$optpendidikan='<option value="D1" '.$P["D1"].'>D1 - DIPLOMA 1</option>
					<option value="D2" '.$P["D2"].'>D2 - DIPLOMA 2</option>
					<option value="D3" '.$P["D3"].'>D3 - DIPLOMA 3</option>
					<option value="S1" '.$P["S1"].'>S1 - STRATA 1</option>
					<option value="S2" '.$P["S2"].'>S2 - STRATA 2</option>
					<option value="23" '.$P["S3"].'>S3 - STRATA 3</option>';
					
	$k = array($jurusan => "selected");				
	$optjurusan=' <option value="Hukum" '.$k["Hukum"].'>Hukum</option>
					<option value="Komputer" '.$k["Komputer"].'>Komputer</option>
					<option value="Akutansi" '.$k["Akutansi"].'>akutansi</option>
					<option value="Ekonomi" '.$k["Ekonomi"].'>ekonomi</option>';
										
	$j = array($jns_kelamin => "selected");					
	$optjnskel = '<option value="L" '.$j["L"].'>Pria</option><option value="P" '.$j["P"].'>Wanita</option>';				
	$conn->disconnect();
}else{
	$BUTTON="Save";
	$SQ = "select max(substr(id_pelamar,2,length(id_pelamar)))+1 from tbllamaran";
	$conn->connect();
	$val = $conn->query($SQ);
	$val->next();
	$id_pelamar = "P".$val->get(0);
	$conn->disconnect();
	
	$optpendidikan=' <option value="D1">D1 - DIPLOMA 1</option>
					<option value="D2">D2 - DIPLOMA 2</option>
					<option value="D3">D3 - DIPLOMA 3</option>
					<option value="S1">S1 - STRATA 1</option>
					<option value="S2">S2 - STRATA 2</option>
					<option value="23">S3 - STRATA 3</option>';
					
	$optjurusan=' <option value="Hukum">Hukum</option>
					<option value="Komputer">Komputer</option>
					<option value="Akutansi">akutansi</option>
					<option value="Ekonomi">ekonomi</option>';					
					
	$optjnskel = '<option value="L">Pria</option><option value="P">Wanita</option>';					
}	
?>
<fieldset class="fieldbox">
<legend class="fieldbox">Form Pendaftaran</legend>
<form id="frmlamaran" name="frmlamaran" method="post" onsubmit="return SaveForm('frmlamaran','SubModules/postLamar.php');" autocomplete="off">
<input type="hidden" name="ACTION" id="ACTION" value="<? echo $BUTTON?>" />
<input type="hidden" name="DATA" id="DATA" value="<? echo $_GET["data"]?>" />
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<table width="100%" border="0" cellpadding="2px" cellspacing="1px">
<tr><td>
   <table width="100%" border="0" cellpadding="3px" cellspacing="0">
    	<tr>	
            <td width="30%">ID Pelamar</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="id_pelamar" name="id_pelamar" size="35" value="<?php echo $id_pelamar ?>" class="required" readonly="readonly"/></td>
        </tr>
        <tr>	
            <td width="30%">Nama</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="nama" name="nama" size="35" value="<?php echo $nama ?>" class="required"/></td>
        </tr>
        <tr>
            <td width="30%">Tempat Lahir</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="tmp_lahir" name="tmp_lahir" size="35" value="<?php echo $tmp_lahir ?>" class="required"/></td>
        </tr>
        <tr>
            <td width="30%">Tanggal Lahir</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="tgl_lahir" name="tgl_lahir" size="35" value="<?php echo $tgl_lahir ?>" onmouseover="formdate('tgl_lahir')" class="required"/></td>
        </tr>
        <tr>
            <td valign="top">Alamat</td>
            <td valign="top">:</td>
          <td><textarea name="alamat" id="alamat" cols="32" rows="2" class="required"><?php echo $alamat ?></textarea></td>
        </tr>
        <tr>
            <td width="30%">Telepon</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="telepon" name="telepon" size="35" value="<?php echo $telepon ?>" class="required"/></td>
        </tr>
        <tr>
            <td width="30%">Jenis Kelamin</td>
            <td width="3%">:</td>
            <td width="70%">
            <select name="jns_kelamin">
          		<?php echo $optjnskel ?>
            </select>
            </td>
        </tr>
        <tr>
            <td width="30%">Status</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="status" name="status" size="35" value="<?php echo $status ?>" class="required"/></td>
        </tr>
        <tr>
            <td width="30%">Pendidikan</td>
            <td width="3%">:</td>
            <td width="70%">
             <select name="pendidikan">
               <?php echo $optpendidikan ?>
            </select>
            </td>
        </tr>
		
        <tr>
            <td width="30%">Jurusan</td>
            <td width="3%">:</td>
            <td width="70%">
             <select name="jurusan">
               <?php echo $optjurusan ?>
            </select>
           </td>
        </tr>
        
        <tr>
            <td width="30%">IPK</td>
            <td width="3%">:</td>
            <td width="70%"><input type="text" id="ipk" name="ipk" size="35" value="<?php echo $ipk ?>"  class="required"/></td>
        </tr>
	 </table>
	</td></tr>
	<tr><td>&nbsp;</td></tr>
  	<tr>
       <td>
               <input type="submit" value="Save" style="display:none;" />
            	<a href="javascript:void(0)" onclick="return SaveForm('frmlamaran','SubModules/postLamar.php');"
                		class="fg-button fg-button-icon-left ui-corner-all fg-button-bg">
                    <span class="ui-icon ui-icon-disk"></span>
                    <? echo $BUTTON ?>
                </a>
                <a href="javascript:void(0)" onclick="ResetForm('#result','frmlamaran')" 
                		class="fg-button fg-button-icon-left ui-corner-all fg-button-bg">
                    <span class="ui-icon ui-icon-closethick"></span>
                    Clear
                </a>
            </td>
        </tr>
		<tr><td>&nbsp;</td></tr>
</table>
</form>
<div id="result" style="display:none;" class=""></div>
</fieldset>
